package com.example.HeadFirstDemo.Singleton;

public class SingletonDemo2 {
    //加载一个空的对象
    private static SingletonDemo2 singletonDemo2;

    private SingletonDemo2(){

    }

    //在使用的时候加载真正的对象
    public static SingletonDemo2 getInstance(){
        //判断对象，为空则赋值
        if(singletonDemo2==null){
            singletonDemo2=new SingletonDemo2();
        }
        return singletonDemo2;
    }
}
